//1. 导入vue-router相关函数
import {createRouter, createWebHashHistory} from "vue-router"
// 2.路由规则
const routes = [
    {
        //首页
        path: "/",
        name: "index",
        redirect: "/home"
    },
    {
        //首页
        path: "/home",
        name: "home",
        component: () => import('@/page/index/index.vue')
    },
    {
        //首页
        path: "/addRecord",
        name: "addRecord",
        component: () => import('@/page/addRecord/index.vue')
    },
    {
        //统计
        path: "/statistics",
        name: "statistics",
        component: () => import('@/page/statistics/index.vue')
    },
    {
        //加工
        path: "/processHome",
        name: "processHome",
        component: () => import('@/page/processHome/ProcessHome.vue')
    },
    {
        //新增加工
        path: "/addProcess",
        name: "addProcess",
        component: () => import('@/page/addProcess/AddProcess.vue')
    },
    {
        //新增归还
        path: "/addProcessDetail",
        name: "addProcessDetail",
        component: () => import('@/page/addProcessDetail/AddProcessDetail.vue')
    },
    {
        //新增归还
        path: "/processDetail",
        name: "processDetail",
        component: () => import('@/page/processDetail/processDetail.vue')
    },
    {
        //新增归还
        path: "/processStatistics",
        name: "processStatistics",
        component: () => import('@/page/processStatistics/ProcessStatistics.vue')
    }
]
// 3.路由对象实例化
const router = createRouter({
    history: createWebHashHistory(),
    routes
})
router.beforeEach((to, from, next) => {
    // console.log("beforeEach to:", to);
    //console.log("beforeEach from", from);
    if (to.path === "/index") {
        sessionStorage["quit"] = 1;
    } else {
        sessionStorage["quit"] = 0;
    }
    next();
});
// 暴露导出
export default router